<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>RVM : Baseline Compiler</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            RVM : Baseline Compiler
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Jul 02, 2008 by <font color="#0050B2">dgrove</font>.
				    </div>

				    <h2><a name="BaselineCompiler-GeneralArchitecture"></a>General Architecture</h2>

<p>The goal of the baseline compiler is to efficiently generate code that is "obviously correct." It also needs to be easy to port to a new platform and self contained (the entire baseline compiler must be included in all Jikes RVM boot images to support dynamically loading other compilers).<br/>
Roughly two thirds of the baseline compiler is machine-independent. The main file is <tt>BaselineCompiler</tt> and its parent <tt>TemplateCompilerFramework</tt>. The main platform-dependent file is <tt>BaselineCompilerImpl</tt>.</p>

<p>Baseline compilation consists of two main steps: GC map computation (discussed below) and code generation.  Code generation is straightforward, consisting of a single pass through the bytecodes of the method being compiled. The compiler does not try to optimize register usage, instead the bytecode operand stack is held in memory. This leads to bytecodes that push a constant onto the stack, creating a memory write in the generated machine code. The number of memory accesses in the baseline compiler corresponds directly to the number of bytecodes. <tt>TemplateCompilerFramework</tt> contains the main code generation switch statement that invokes the appropriate <tt><em>emit</em>&lt;bytecode&gt;&#95;</tt> method of <tt>BaselineCompilerImpl</tt>.</p>

<h2><a name="BaselineCompiler-GCMaps"></a>GC Maps</h2>

<p>The baseline compiler computes GC maps by abstractly interpreting the bytecodes to determine which expression stack slots and local variables contain references at the start of each bytecode. There are additional compilations to handle <tt>JSR</tt>s; see the source code for details. This strategy of computing a single GC map that applies to all the internal GC points for each bytecode slightly constrains code generation. The code generator must ensure that the GC map remains valid at all GC points (including implicit GC points introduced by null pointer exceptions). It also forces the baseline compiler to report reference parameters for the various <tt>invoke</tt> bytecodes as live in the GC map for the call (because the GC map also needs to cover the various internal GC points that happen before the call is actually performed). Note that this is not an issue for the optimizing compiler which computes GC maps for each machine code instruction that is a GC point.</p>

<h2><a name="BaselineCompiler-CommandLineOptions"></a>Command-Line Options</h2>

<p>The command-line options to the baseline compiler are stored as fields in an object of type <tt>BaselineOptions</tt>; this file is mechanically generated by the build process. To add or modify the command-line options in <tt>BaselineOptions.java</tt>, you must modify either <tt>BooleanOptions.dat</tt>, or <tt>ValueOptions.dat</tt>. You should describe your desired command-line option in a format described below in the appendix; you will also find the details for the optimizing compiler's command-line options. Some options are common to both the baseline compiler and optimizing compiler. They are defined by the <tt>SharedBooleanOptions.dat</tt> and <tt>SharedValueOptions.dat</tt> files found in the <tt>rvm/src-generated/options</tt> directory. </p>

				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="http://docs.codehaus.org/images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Jul 04, 2010 19:57</font></td>
		    </tr>
	    </table>
    </body>
</html>